/*
 * Achieve it All! - Android app to motivate achieving your goals
 * Copyright (C) 2014  Xilconic
 * 
 * This file is part of Achieve it All!.
 *
 * Achieve it All! is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Achieve it All! is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Achieve it All!.  If not, see <http://www.gnu.org/licenses/>
 */
package com.xilconic.achieveitall.fragments.goalsoverview;

import com.xilconic.achieveitall.R;
import com.xilconic.achieveitall.domain.GoalsOverview;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

public class GoalsOverviewFragment extends Fragment {
	private GoalsOverview overview;
	private GoalsOverviewExpandableListAdapter adapter;
	
    /**
     * {@link Fragment} argument representing the {@link GoalsOverview} being
     * visualized in the fragment.
     */
    private static final String ARG_GOALS_OVERVIEW = "goals_overview";

	public static GoalsOverviewFragment newInstance(GoalsOverview overview){
		GoalsOverviewFragment fragment = new GoalsOverviewFragment();
		
		Bundle args = new Bundle();
		args.putParcelable(ARG_GOALS_OVERVIEW, overview);
		fragment.setArguments(args);
		
		return fragment;
	}
	
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_goals_overview,
                container, false);
        
        Bundle arguments = getArguments();
        overview = (GoalsOverview)arguments.getParcelable(ARG_GOALS_OVERVIEW);

        return rootView;
    }
    
    @Override
    public void onActivityCreated(Bundle savedInstanceState){
    	super.onActivityCreated(savedInstanceState);
    	
    	ExpandableListView listView = (ExpandableListView)getView().
    			findViewById(R.id.fragment_goalsoverview_ExpandableList);
    	adapter = new GoalsOverviewExpandableListAdapter(overview, getActivity());
    	listView.setAdapter(adapter);
    }
    
}
